/*
*
* post page script
* views -> post
* */
(function (gb_config, $, window, document){

    var getQueryString = utilsLoad.getQueryString,
        delQueryUrl = utilsLoad.delQueryUrl,
        getCookie = utilsLoad.getCookie,
        myLoading = utilsLoad.myLoading,
        unMyLoading = utilsLoad.unMyLoading;

    /*
       * 1、职位 post index.ejs
       * 初始化搜索条件
       * */
    gb_config.init_post_condition = function (){

        // 定义condition对象
        var thisObj = {
            // init
            init: function (){

                // 筛选条件，初始赋值
                var wd = getQueryString('wd'),
                    lan = getQueryString('lan') || '""',
                    work_prop = getQueryString('work_prop') || '""',
                    post_1st = getQueryString('post_1st') || '""',
                    post_2nd = getQueryString('post_2nd') || '""',
                    work_exp = getQueryString('work_exp') || '',
                    degree = getQueryString('degree') || '',
                    min_salary = getQueryString('min_salary') || '',
                    max_salary = getQueryString('max_salary') || '',
                    assign = getQueryString('assign') || '',
                    date = getQueryString('date') || '';


                if(lan && lan !== '""'){
                    $('div.lan>div').addClass('more');
                    $('.moreCondition').addClass('down').html('收起');
                }

                $('.searchPost').val(wd);
                // 语言要求
                if(lan.indexOf(',') >= 0){
                    lan.split(',').forEach(item => {
                        $('div.lan').find('.condition[data-cd='+ item +']').addClass('current')
                    })
                }else{
                    $('div.lan').find('.condition[data-cd='+ lan +']').addClass('current')
                }

                // 工作类型
                if(work_prop.indexOf(',') >= 0){
                    work_prop.split(',').forEach(item => {
                        $('div.work_prop').find('.condition[data-cd='+ item +']').addClass('current')
                    })
                }else{
                    $('div.work_prop').find('.condition[data-cd='+ work_prop +']').addClass('current')
                }

                // 职位类型（一级）
                var type1Condition = $('div.post_1st').find('.condition[data-cd='+ post_1st +']'),
                    index = type1Condition.index(),
                    type2Condition = $('div.post_2nd>div').eq(index-1);
                type1Condition.addClass('current');
                // 二级
                if(index > 0){
                    type2Condition.removeClass('hidden');
                    if(post_2nd.indexOf(',') >= 0){
                        post_2nd.split(',').forEach(item => {
                            type2Condition.find('.condition[data-cd='+ item +']').addClass('current');
                        })
                    }else{
                        type2Condition.find('.condition[data-cd='+ post_2nd +']').addClass('current');
                    }
                }

                // 下拉框
                $('select.experience').val(work_exp);
                $('select.degree').val(degree);
                $('select.isWaipai').val(assign);
                $('select.publishTime').val(date);
                if(min_salary || max_salary){
                    $('select.salary').val(min_salary + '-' + max_salary)
                }
                layui.form.render('select')
            },
            // 设置URL参数（单选）
            resetQuerySearch: function (type, value) {
                var result = '',
                    search = location.search;
                result = delQueryUrl(search, type);
                if(value){
                    result = result + (result ? `&${type}=` : `?${type}=`) + value
                }
                location.search = result
            },
            // 设置URL参数（多选）
            resetMultiQuerySearch: function (type, value, cancel) {
                var query = getQueryString(type),
                    queryArr = null,
                    index = -1;
                var _value = value;
                // 存在参数
                if(query){
                    // -1代表取消
                    if(cancel || cancel === -1){
                        queryArr = query.split(',');
                        index = queryArr.indexOf(value);
                        index >= 0 && queryArr.splice(index, 1);
                        _value = queryArr.join(',')
                    }else{
                        _value = query + ',' + value
                    }
                }
                var result = '',
                    search = location.search;
                result = delQueryUrl(search, type);
                if(_value){
                    result = result + (result ? `&${type}=` : `?${type}=`) + _value
                }
                location.search = result
            },
            /*
            * 策略模式
            * 根据type类型，添加/移除URL参数
            * */
            setQueryParams: function (type, value, config = {}) {

                // 获取筛选类型
                var resultType = actionTypes(type, config);

                // 执行筛选
                this.filter(resultType, type, value);

                /*
                * 返回搜索筛选类型
                * return 1：关键字搜索、工作经验、学历要求、是否外派、发布时间
                * return 2：薪资范围
                * return 3：职位类型（一级）
                * return 4：选中：职位类型（二级）、语言要求、工作性质
                * return 5：取消：职位类型（二级）、语言要求、工作性质
                * return 6：重置：职位类型（二级）、语言要求、工作性质
                * */
                function actionTypes(type, conf) {
                    switch (type) {
                        case 'wd':case 'work_exp':case 'degree':
                        case 'assign':case 'date': {
                            return 1
                        }
                        case 'salary': {
                            return 2
                        }
                        case 'post_1st': {
                            return 3
                        }
                        case 'lan':case 'work_prop':case 'post_2nd': {
                            if(conf.reset){
                                return 6
                            }
                            if(conf.cancel){
                                return 5
                            }
                            return 4
                        }
                    }
                }
            },
            // 执行策略（筛选）
            filter: function (resultType, type, value){
                var _this = this;
                var result = location.search;
                switch (resultType) {
                    case 1: {
                        _this.resetQuerySearch(type, value);
                        break
                    }
                    case 2: {
                        var salary = null;
                        salary = value
                               ? value.split('-')
                               : ['', ''];
                        result = delQueryUrl(result, 'min_salary');
                        result = delQueryUrl(result, 'max_salary');
                        if(salary[0] || salary[1]){
                            result = result + (result ? `&min_salary=` : `?min_salary=`) + salary[0];
                            result = result + (result ? `&max_salary=` : `?max_salary=`) + salary[1];
                        }
                        location.search = result;
                        break
                    }
                    case 3: {
                        result = delQueryUrl(result, "post_1st");
                        result = delQueryUrl(result, "post_2nd");
                        result = delQueryUrl(result, "post_3rd");
                        if(value){
                            result = result + (result ? `&${type}=` : `?${type}=`) + value;
                        }
                        location.search = result;
                        break
                    }
                    case 4: {
                        _this.resetMultiQuerySearch(type, value);
                        break
                    }
                    case 5: {
                        _this.resetMultiQuerySearch(type, value, -1);
                        break
                    }
                    case 6: {
                        _this.resetQuerySearch(type, value);
                        break
                    }
                }

            }
        };

        thisObj.init();

        // click事件委托
        $('.postElem').on('click', function (e) {
            var $tar = $(e.target);
            // 搜索职位名
            if($tar.hasClass('searchBtn')){
                var post = $tar.prev().val().trim() || '';
                if(!post){
                    layer.msg('请输入搜索关键字', {icon: 5});
                    return false
                }
                thisObj.setQueryParams("wd", post)
            }
            /*
            *  ******  搜索：条件筛选  ******
            * */
            // 清空筛选条件
            if($tar.hasClass('clearCondition')){
                location.href = location.pathname + ''
            }
            // 展开“更多”
            if($tar.hasClass('moreCondition')){
                $tar.toggleClass('down');
                $tar.prev('div').toggleClass('more');
                $tar.html($tar.hasClass('down') ? '收起' : '更多>');
            }
            // 筛选条件
            if($tar.hasClass('condition')){
                // 搜索
                var key = $tar.attr('data-type'),
                    value = $tar.attr('data-cd') || '';
                switch (key) {
                    case 'post_1st': {
                        thisObj.setQueryParams(key, value);
                        break
                    }
                    case 'lan': case 'work_prop': case 'post_2nd': {
                        // 重置
                        if($tar.hasClass('all')){
                            thisObj.setQueryParams(key, '', {
                                reset: true
                            })
                        } // 取消
                        else if($tar.hasClass('current')) {
                            thisObj.setQueryParams(key, value, {
                                cancel: true
                            })
                        } // 选中
                        else{
                            thisObj.setQueryParams(key, value)
                        }
                        break
                    }
                }
            }
        });

        // 搜索：下拉框筛选
        layui.use('form', function () {
            var form = layui.form;
            // 工作经验
            form.on('select(experience)', function(data){
                thisObj.setQueryParams("work_exp", data.value)
            });
            // 学历要求
            form.on('select(degree)', function(data){
                thisObj.setQueryParams("degree", data.value)
            });
            // 薪资要求
            form.on('select(salary)', function(data){
                thisObj.setQueryParams('salary', data.value)
            });
            // 是否接受外派
            form.on('select(isWaipai)', function(data){
                thisObj.setQueryParams("assign", data.value)
            });
            // 发布时间
            form.on('select(publishTime)', function(data){
                thisObj.setQueryParams("date", data.value)
            });
        })
    };

    /*
       * 2、职位 index.ejs
       * 列表
       * */
    gb_config.init_post_list = function (){

        // 定义对象
        var thisObj = {
            // init
            init: function (){

                this.filterPost();
                getCookie('USER_TOKEN') && this.seenPost()
            },
            // 看过的职位（登录后可见）
            seenPost: function (){
                var userCode = '';
                if(getCookie('USER_BASE')){
                    userCode = getCookie('USER_BASE').split(',')[0];
                }
                $.ajax({
                    url: API_BASE_URL+'/userCenter/positionBrowsed',
                    data: {
                        userCode: userCode || ''
                    }
                }).done(function (res) {
                    if(res.message === 'success' && res.data && res.data.length){
                        var html = '<h3>看过的职位</h3>';
                        res.data.slice(0, 3).forEach(item => {
                            html += `<div class="layui-row">
                                        <div class="layui-col-md8">
                                            <a class="txt-ellipsis" href="/post/${item.positionCode}.html" title="${item.positionTitle}" target="_blank">${item.positionTitle}</a>
                                            <span class="company">${item.companyName}</span>
                                        </div>
                                        <div class="layui-col-md4">
                                            <span class="salary">${item.salaryFloor/1000}K-${item.salaryCeiling/1000}K</span>
                                        </div>
                                    </div>`
                        });
                        $('.rightCnt').append(`<section class="post">${html}</section>`)
                    }
                })
            },
            // empty
            $empty: `<div class="data-empty"></div>`,
            // container
            $container: $('.searchList'),
            // 渲染模板
            template: function (item){
                var company = item.company || {},
                    labels = (item.positionLabel && item.positionLabel.split(',')) || [];
                var labelStr = labels.reduce((prevLabel, label) => {
                    return prevLabel + `<label>${label}</label>`
                }, '');
                var city = item.city.indexOf('市') >= 0 ? item.city.slice(0,-1) : item.city;
                return `<div class="item ${item.isExpatriate ? 'wp' : ''}">
                            <div class="layui-row">
                                <div class="layui-col-md6 _post">
                                    <a href="/post/${item.positionCode}.html" target="_blank">
                                        <h3 class="title txt-ellipsis">${item.positionTitle}</h3>
                                        <span class="location">${city && ('['+ city +']') }</span>
                                    </a>
                                    <span class="time">${item.gmtRelease && item.gmtRelease.slice(0, 10)} 发布</span>
                                    <div class="short">
                                        <span class="salary">${item.salaryFloor/1000 + 'K-' + item.salaryCeiling/1000 + 'K' + item.unit}</span>
                                        <span class="post">${item.language} / ${item.experience} / ${item.degree} / ${item.positionProperty}</span>
                                    </div>
                                </div>
                                <div class="layui-col-md4 _company">
                                    <a href="/post/company/${company.id}.html" target="_blank">
                                        <h3 class="company txt-ellipsis">${company.companyName}</h3>
                                    </a>
                                    <div class="type">${company.companyProperty} / ${company.scale}</div>
                                </div>
                                <div class="layui-col-md2">
                                    <a href="/post/company/${company.id}.html" target="_blank">
                                        ${company.logoUrl ? '<img src="'+company.logoUrl+'" alt="">' : '<div class="short-name">'+ company.companySimpleName.slice(0,4) +'</div>'}
                                    </a>
                                </div>
                            </div>
                            <div class="label">${labelStr}</div>
                        </div>`
            },
            // 分页
            pagination: function (config){
                if(config.total <= 0){
                    $('#pagination').empty();
                    return false
                }
                layui.laypage.render({
                    elem: 'pagination'
                    ,count: config.total
                    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    ,limits: [10,20,50]
                    ,prev: '<i class="layui-icon"></i>'
                    ,next: '<i class="layui-icon"></i>'
                    ,curr: config.curr
                    ,limit: config.size
                    ,first: '1'
                    ,last: '尾页'
                    ,jump: function(obj, first){
                        if(!first){
                            thisObj.filterPost({
                                curr: obj.curr,
                                size: obj.limit
                            })
                        }
                    }
                })
            },
            // 筛选职位
            filterPost: function (config) {
                config = config || {};
                config.curr = config.curr || 1;
                config.size = config.size || 10;
                var data = {
                    location: decodeURIComponent(getCookie('CURRENT_CITY')) || '',
                    pageNo: config.curr,
                    pageSize: config.size,
                    positionTitle: getQueryString('wd') || '',
                    languageCode: getQueryString('lan') || '',
                    intendPositionProperty: getQueryString('work_prop') || '',
                    firstPositionCategoryCode: getQueryString('post_1st') || '',
                    secondPositionCategoryCode: getQueryString('post_2nd') || '',
                    thridPositionCategoryCode: getQueryString('post_3rd') || '',
                    workYears: getQueryString('work_exp') || '',
                    degreeRequire: getQueryString('degree') || '',
                    salaryFloorRequire: getQueryString('min_salary') ? (+getQueryString('min_salary') * 1000) : '',
                    salaryCeilingRequire: (+getQueryString('max_salary') * 1000) || '',
                    expatriate: getQueryString('assign') || '',
                    publishDateTime: getQueryString('date') || ''
                };
                var _this = this;
                $.ajax({
                    type: 'get',
                    url: API_BASE_URL + '/userCenter/listNewestPosition',
                    data: data,
                    beforeSend() { myLoading() },
                    complete() { unMyLoading() }
                }).done(res => {
                    if(res.message === 'success' && typeof res.data === 'object'){
                        var { results, totalCount } = res.data,
                            template = _this.template;
                        var html = (results || []).reduce((prev, item) => {
                            return prev + template(item)
                        }, '');
                        _this.$container.html(html);
                        _this.pagination({
                            curr: config.curr,
                            size: config.size,
                            total: totalCount
                        });
                        // 0条数据，展示空图片
                        if(totalCount <= 0){
                            _this.$container.html(_this.$empty)
                        }
                    }else{
                        layer.alert(res.message, {
                            title: '操作提示',
                            time: 3000,
                            btn: ['关闭'],
                            shadeClose: true,
                            icon: 2
                        })
                    }
                })
            }
        };

        thisObj.init()

    };

    /*
       * 3、职位 detail.ejs
       * 职位详情
       * */
    gb_config.init_post_detail = function (){

        // 定义对象
        var thisObj = {
            // 职位ID
            postID: $('.postID').val(),
            // init
            init: function (){

                // 非正式环境 打印
                getCookie('CURRENT_ENV') !== 'production' && $reAjax({
                    url: API_BASE_URL+'/userCenter/positionDetail',
                    data: {
                        positionCode: thisObj.postID
                    }
                }, function (res) {
                    res = res.responseJSON;
                    console.log(res);
                })
            },
            // 收藏/取消收藏职位
            collectPost: function (elem, isCollect) {

                $.ajax({
                    url: API_BASE_URL + '/userCenter/colllectPosition',
                    data: {
                        positionCode: this.postID,
                        flag: isCollect ? 0 : 1
                    }
                }).done(function (res) {
                    if(res.message === 'success'){
                        layer.msg(isCollect ? '已成功收藏':'已取消收藏');
                        isCollect ? elem.addClass('selected') : elem.removeClass('selected')
                    }else{
                        layer.alert(res.message, {
                            title: '操作提示',
                            time: 3000,
                            btn: ['关闭'],
                            shadeClose: true,
                            icon: 2
                        })
                    }
                })
            },
            // 投递简历 判断是否完善简历/获取简历
            deliver_resumeFiles: function (elem){
                var _this = this;
                $.ajax({
                    url: API_BASE_URL + '/userCenter/judgeResumeComplete',
                    beforeSend() {
                        elem.attr('disabled', true)
                    }
                }).done(function(res) {
                    if(res.message === 'success'){
                        // 已完善
                        if(res.data){
                            $.ajax({
                                url: API_BASE_URL + '/userCenter/selectPersonalResume',
                                success: function(res1) {
                                    _this.deliver_resumeModal(true, res1.data)
                                }
                            })
                        }else{
                            _this.deliver_resumeModal(false)
                        }
                    }
                })
            },
            // 投递简历 模态框
            deliver_resumeModal: function (isComplete, data) {
                if(Object.prototype.toString.call(data) !== '[object Array]'){
                    data = []
                }
                var content = '';

                // 未完善
                if(!isComplete){
                    content = `
                        <div class="layui-form-item">
                            <p class="msg">系统检测到你的在线简历还没有完善</p>
                        </div>
                        <div class="layui-form-item align-right">
                            <a class="layui-btn layui-btn-primary" href="/my/resume">去完善</a>
                            <a class="layui-btn layui-btn-primary" href="/my/resume">上传简历</a>
                        </div>
                    `
                }else{ // 已完善，附件/在线简历
                    var files = ``;
                    data.forEach(item => {
                        if(item.resumeType === '在线简历'){
                            files +=`<div class="item">
                                        <input type="radio" name="deliver" value="${item.id}" data-type="${item.resumeType}">
                                        <span class="file txt-ellipsis">在线简历</span>
                                        <span class="operate">
                                            <a href="/my/resume">预览</a> | <a href="/my/resume">修改</a>
                                        </span>
                                      </div>`
                        }else{
                            files +=`<div class="item">
                                        <input type="radio" name="deliver" value="${item.id}" data-type="${item.resumeType}">
                                        <span class="file txt-ellipsis" title="${item.attachResumeName}">附件简历：${item.attachResumeName}</span>
                                        <span class="operate align-right">
                                            <a href="${item.attachVisitUrl}" download target="_blank">下载</a>
                                        </span>
                                      </div>`
                        }
                    });
                    if(data.length >= 4){
                        data.length = data.length - 1
                    }else{
                        files += `<div class="item"><a href="/my/resume">上传附件简历</a></div>`
                    }
                    content = `
                        <div class="layui-form-item padding" style="height: ${36*(1+(data.length?data.length:0))}px">${files}</div>
                        <div class="layui-form-item align-right">
                            <button class="layui-btn layui-btn-primary" type="button" onclick="layer.closeAll()">取消</button>
                            <button class="layui-btn confirmDeliverResume" type="button">确定</button>
                        </div>
                    `
                }
                layer.open({
                    type: 1,
                    title: '投递简历',
                    area: ['400px'],
                    content:`<form class="layui-form deliver" lay-filter="deliverForm" onsubmit="return false">${content}</form>`,
                    success: function (){
                        layui.form.render('radio', 'deliverForm');
                        // 确认投递
                        var confirm = document.querySelector('.confirmDeliverResume');
                        confirm && (confirm.onclick = function () {
                            var $radio = $('[name="deliver"]:checked');
                            if(!$radio.length){
                                layer.msg('请选择需投递的简历', {icon: 5});
                                return false
                            }
                            thisObj.deliver_resume({
                                elem: this,
                                resumeId: $radio[0].value,
                                resumeType: $radio[0].getAttribute('data-type')
                            })
                        })
                    }
                });
                $('.deliverResume').removeAttr('disabled')
            },
            // 确认 投递简历
            deliver_resume: function (conf) {
                var postID = this.postID;
                var { resumeId, resumeType, elem } = conf;
                $reAjax({
                    method: 'post',
                    url: API_BASE_URL + '/userCenter/deliveryResume',
                    contentType: 'form',
                    data: {
                        positionCode: postID,
                        resumeId: resumeId,
                        resumeType: resumeType
                    }
                }, function (res) {
                    res = res.responseJSON;
                    if(res.message === 'success' && res.data === true){
                        layer.closeAll();
                        layer.msg('已成功投递简历');
                        $('.deliverResume')
                            .attr('disabled', true)
                            .removeClass('checkUserLogin deliverResume')
                            .html('已投递')
                    }else{
                        layer.alert(res.message, {
                            title: '操作提示',
                            time: 3000,
                            btn: ['关闭'],
                            shadeClose: true,
                            icon: 2
                        })
                    }
                    $(elem).removeAttr('disabled')
                }, function () {
                    $(elem).attr('disabled',true)
                })
            }
        };

        thisObj.init();

        // click 事件委托
        $('.postDetail').on('click', function (e) {
            var $tar = $(e.target);
            // 判断是否登录
            if($tar.hasClass('checkUserLogin')){
                if(!getCookie('USER_TOKEN')){
                    $('.signModal')[0].click();
                    e.preventDefault();
                    return false
                }
                // 投递简历
                if($tar.hasClass('deliverResume')){
                    thisObj.deliver_resumeFiles($tar)
                }
                // 收藏/取消收藏职位
                if($tar.hasClass('collect')){
                    var isCollect = $tar.hasClass('selected');
                    thisObj.collectPost($tar, !isCollect)
                }
            }
        })
    };

    /*
       * 4、职位 company.ejs
       * 公司详情
       * */
    gb_config.init_company_detail = function (){

        // 定义对象
        var thisObj = {
            companyID: $('.companyID').val(),
            // 初始化
            init: function (){

                this.initCompanyCd();
                this.filterPost()
            },
            // 获取工作语言、工作地点
            initCompanyCd: function (){
                var _this = this;
                // 工作地点
                $.ajax({
                    url: API_BASE_URL + '/userCenter/selectAllLocation',
                    data: {
                        companyId: _this.companyID
                    }
                }).done(function (res) {
                    if(res.message === 'success'){
                        var html = res.data.reduce((prev, item) => {
                            return prev + `<option value="${item}">${item}</option>`
                        }, '');
                        $('[name="postCity"]').append(html);
                        layui.form.render('select')
                    }
                });
                // 获取语言
                $.ajax({
                    url: API_BASE_URL + '/userCenter/selectAllLanguage',
                    data: {
                        companyId: _this.companyID
                    }
                }).done(function (res) {
                    if(res.message === 'success'){
                        var html = res.data.reduce((prev, item) => {
                            return prev + `<option value="${item.languageCode}">${item.languageName}</option>`
                        }, '');
                        $('[name="postLanguage"]').append(html);
                        layui.form.render('select')
                    }
                })
            },
            // empty
            $empty: `<div class="data-empty"></div>`,
            // container
            $container: $('.searchList'),
            // 渲染模板
            template: function (item){
                return `<div class="item ${item.isExpatriate ? 'wp' : ''}">
                            <div class="title">
                                <a href="/post/${item.positionCode}.html" target="_blank">
                                    <h3 class="post float-l txt-ellipsis">${item.positionTitle}</h3>
                                </a>
                                <span class="time float-l">${item.gmtRelease && item.gmtRelease.slice(0,10)} 发布</span>
                                <span class="salary float-r">${item.salaryFloor/1000}K-${item.salaryCeiling/1000}K${item.unit}</span>
                            </div>
                            <div class="post-short">${item.positionProperty} / ${item.language} / ${item.experience} / ${item.degree}</div>
                        </div>`
            },
            // page
            pagination: function (config){
                if(config.total <= 0){
                    $('#pagination').empty();
                    return false
                }
                layui.laypage.render({
                    elem: 'pagination'
                    ,count: config.total
                    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    ,limits: [10,20,50]
                    ,prev: '<i class="layui-icon"></i>'
                    ,next: '<i class="layui-icon"></i>'
                    ,curr: config.curr
                    ,limit: config.size
                    ,first: '1'
                    ,last: '尾页'
                    ,jump: function(obj, first){
                        if(!first){
                            thisObj.filterPost({
                                curr: obj.curr,
                                size: obj.limit
                            })
                        }
                    }
                })
            },
            // 筛选职位
            filterPost: function (config) {
                config = config || {};
                config.curr = config.curr || 1;
                config.size = config.size || 10;
                var _this = this;
                var data = {
                    companyId: _this.companyID,
                    pageNo: config.curr,
                    pageSize: config.size,
                    city: _this.filterConfig.city,
                    languageCode: _this.filterConfig.language,
                    positionTitle: _this.filterConfig.post
                };

                $.ajax({
                    type: 'get',
                    url: API_BASE_URL + '/userCenter/companyPublishPositionDetail',
                    data: data,
                    beforeSend() { myLoading() },
                    complete() { unMyLoading() }
                }).done(res => {
                    if(res.message === 'success' && typeof res.data === 'object'){
                        var { results, totalCount } = res.data,
                            template = _this.template;
                        var html = (results || []).reduce((prev, item) => {
                            return prev + template(item)
                        }, '');
                        _this.$container.html(html);
                        _this.pagination({
                            curr: config.curr,
                            size: config.size,
                            total: totalCount
                        });
                        // 0条数据，展示空图片
                        if(totalCount <= 0){
                            _this.$container.html(_this.$empty)
                        }
                    }else{
                        layer.alert(res.message, {
                            title: '操作提示',
                            time: 3000,
                            btn: ['关闭'],
                            shadeClose: true,
                            icon: 2
                        })
                    }
                })
            },
            // 搜索条件
            filterConfig: {
                city: '',
                language: '',
                post: ''
            }
        };

        thisObj.init();

        // 搜索
        layui.form.on('submit(search_post)', function (data) {
            thisObj.filterConfig.city = data.field.postCity;
            thisObj.filterConfig.language = data.field.postLanguage;
            thisObj.filterConfig.post = data.field.postName;
            thisObj.filterPost()
        })
    };


    // 全局替换
    window.gb_config_obj = gb_config;

})(window.gb_config_obj || {}, jQuery, window, document);